package com.gqb.wangyi;

import java.util.Scanner;


public class wangyithree {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		while (scanner.hasNext()) {
			int x=scanner.nextInt();
			int y=scanner.nextInt();
			int mushroomCount=scanner.nextInt();
			int[][] mushs=new int[x][y];
			for (int i = 1; i <=mushroomCount; i++) {
				int a=scanner.nextInt();
				int b=scanner.nextInt();
				mushs[a][b]++;
			}
			int mostCount=0;
			int xLoc=0,yLoc=0;
			for(int i=3;i<=x;i++){
				for (int j = 3; j <=y; j++) {
					int first=findMushroomCount(i, j, mushs);
					if(first>mostCount){
						mostCount=first;
						xLoc=i;
						yLoc=j;
					}
				}
			}
			for (int i = xLoc-2; i <=xLoc; i++) {
				for (int j = xLoc-2; j <=xLoc; j++) {
					if(mushs[i][j]>0){
						mushs[i][j]--;
					}
				}
			}
			int mostCount2=0;
			for(int i=3;i<=x;i++){
				for (int j = 3; j <=y; j++) {
					int first=findMushroomCount(i, j, mushs);
					if(first>mostCount2){
						mostCount2=first;
					}
				}
			}
			System.out.println(mostCount+mostCount2);
		}
	}
	
	public static int findMushroomCount(int x,int y,int[][] mushs){
		int count=0;
		for (int i = x-2; i <=x; i++) {
			for (int j = y-2; j <=y; j++) {
				if(mushs[i][j]!=0){
					count++;
				}
			}
		}
		return count;
	}
}
